///////////////////////////////////////////////////////////
//  EditItemCommand.cpp
//  Implementation of the Class EditItemCommand
//  Created on:      21-Sep-2013 12:09:46 PM
//  Original author: Jakkaphan Aiemcharoenjit
///////////////////////////////////////////////////////////

#include "EditItemCommand.h"
#include "CurrentCommand.h"

using namespace UI;
using namespace UI::CMD;

EditItemCommand::EditItemCommand(CCreateItemView* createItem, CCreateTemplateView* createTemplate)
{
  this->m_type = ICommand::EDITITEM_CMD;
  this->m_createItemView = createItem;
  this->m_createTemplateView = createTemplate;
}


EditItemCommand::~EditItemCommand()
{

}


void EditItemCommand::Execute()
{
  IObject* data = this->m_createTemplateView->GetCurrentData();
  std::string name = "";
  switch(data->GetType())
  {
  case IObject::ITEM_T:
    {
      name = dynamic_cast<IItem*>(data)->GetName();
    }
    break;
  case IObject::HEARDER_T:
    {
      name = dynamic_cast<IHeader*>(data)->GetName();
    }
    break;
  default: break;
  }
  this->m_createItemView->SetNameLabel(name);
  this->m_createItemView->SetTitleView("Edit item");
  this->m_createItemView->ItemTypeEnable(false);
   
  // Set current command
  CurrentCommand::GetInstance()->SetCurrentCommand(this->m_type);
}


ICommand::CommandType EditItemCommand::GetType()
{
	return this->m_type;
}